{include file="public/header-static"/}
{include file="public/sidebar"/}
<div id="main">
    {include file="public/header"/}
    <style>
        .datas {
            /*text-align: center;*/
        }

        .d-fix {
            display: flex;
        }
    </style>
    <div class="main-content">
        <div class="container">
            <div class="row">
                <div class="col-md-12">
                    <div class="row">
                    </div>

                </div>
            </div>

            <div class="list">
                <!--                                <div class="uname">用户列表</div>-->
                <div class="app-block">
                    <div class="app-content">
                        <div class="app-action">

                            <div class="action-left">
                                <ul class="list-inline">
                                    <li class="list-inline-item mb-0">
                                        <a href="#" onclick="add()" class="btn btn-secondary myColor">
                                            ✚ 发布社群
                                        </a>
                                    </li>

                                </ul>
                            </div>

                            <div class="action-right" style="margin-left: 0.5rem;">
                                <a href="#" class="app-sidebar-menu-button btn btn-outline-light">
                                    <i data-feather="menu"></i>
                                </a>
                                <div class="input-group">
                                    <input type="text" name="keywords" id="keywords" autofocus="autofocus"
                                           value="{$Request.get.keywords}" class="form-control"
                                           placeholder="社群|行业|企业|创建者"
                                           aria-describedby="button-addon1">
                                    <div class="input-group-append">
                                        <button class="btn btn-outline-light" type="submit" id="button-addon1">
                                            <i data-feather="search"></i>
                                        </button>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="row">
                            <div class="col-md-12">
                                <div class="card">
                                    <table id="linkstable" lay-filter="linkstable"></table>
                                </div>

                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    {include file="public/footer"/}
</div>
<script src="__STATIC__/vendors/charts/chartjs/chart.min.js"></script>
<script src="__STATIC__/vendors/charts/apex/apexcharts.min.js"></script>
<script src="__STATIC__/vendors/circle-progress/circle-progress.min.js"></script>
<script src="__STATIC__/assets/js/examples/dashboard.js"></script>
<script src="__STATIC__/assets/js/examples/echarts.js"></script>
<script src="__STATIC__/assets/js/custom.js"></script>

<script type="text/html" id="barDemo">
    <button class="btn btn-sm btn-outline-info" onclick="edit({{d.id}})">编辑</button><br>
    <button class="btn btn-sm btn-outline-secondary" onclick="communityShow({{d.id}})">详情</button><br>
    <button class="btn btn-sm btn-outline-danger" onclick="communityDel({{d.id}})">删除</button>
</script>
<script>

    // 添加
    function add() {
        window.location.href = '{:url("/community/communityAdd")}';
    }

    // 编辑
    function edit(id) {
        window.location.href = '{:url("/community/communityEdit")}?id=' + id;
    }

    // 企业社群详情
    function communityShow(id) {
        window.location.href = '{:url("/community/communityShow")}?id=' + id;
    }

    // 删除
    function communityDel(id) {
        layer.confirm('删除该数据?', {
            icon: 3,
            title: '提示'
        }, function (index) {
            $.post('{:url("/community/changeStatus")}', {
                id: id
            }, function (data) {
                if (data['code'] != 1) {
                    toastr.error(data['msg']);
                } else {
                    window.location.reload();
                }
            });
            layer.close(index);
        });
    }

    // layui插件
    layui.use('table', function () {
        var table = layui.table
            , form = layui.form;
        // 表格初始化
        table.render({
            elem: '#linkstable'
            , skin: 'line' //行边框风格
            , even: true //开启隔行背景
            , url: '{:url("/community/index")}'
            , method: 'post'
            , page: true //开启分页
            , cols: [[
                {field: 'id', title: 'ID'}
                , {field: 'name', title: '社群'}
                , {field: 'logo', title: '封面图'}
                , {field: 'cname', title: '行业'}
                , {field: 'city_name', title: '地区'}
                , {field: 'create_time', title: '创建时间'}
                , {field: 'qrcode', title: '二维码'}
                , {field: 'headimg', title: '创建者'}
                , {field: 'rightbtn', title: '操作', align: 'center', toolbar: '#barDemo'}
            ]],
            done: function (res) {
                var element = $('td[data-field="rightbtn"]').children('.layui-table-cell');
                element.css('overflow', 'visible');
                element.children('.dropdown-menu').css('min-width', 'auto');

                var element1 = $('td[data-field="introduce"]').children('.layui-table-cell');
                element1.css('white-space', 'nowrap');
            },
            parseData: function (res) {
                return {
                    "code": res.code,
                    "msg": res.msg,
                    "count": res.data.count,
                    "data": res.data.list
                };
            }
        });

        // 搜索
        $('#button-addon1').on('click', function () {
            var keywords = $("#keywords").val();
            table.reload('linkstable', {
                url: '{:url("/community/index")}'
                , where: {
                    keywords: keywords // 搜索参数
                }
                , page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
        });

    });

</script>
<style>
    .card-dth {
        padding: 8px;
    }

    .user-name {
        font-size: 16px;
        font-family: 'AliM';
        font-weight: 500;
        color: #0E1525;
        margin-left: 10px;
        text-align: center;
    }

    .d-cnter {
        text-align: center;
        margin-top: 15px;
    }

    .user {
        display: flex;
        justify-content: space-between;
    }

    .d-rigth {
        text-align: -webkit-center;
    }

    .user {
        width: 96%;
        margin: auto;
        color: #0E1525;

    }

    .bg-txt {
        display: flex;
        margin-top: 5px;
    }


    .str {
        font-size: 12px;
        margin-left: 3px;
        color: #999999;
    }


    .d-fix {
        display: flex;
        justify-content: space-between;
        padding-top: 10px;
        width: 70%;
        margin: auto;
        padding-bottom: 20px;
    }

    .rig-img img {
        width: 9rem;
        height: 9rem;
    }

    .kuai {
        width: 10px;
        height: 10px;
        margin-top: 3px;
        border-radius: 50px;
    }

    .y {
        background: #5B78FF;
    }

    .v {
        background: #F25021;
    }

    .dleft {
        font-size: 18px;
        font-family: 'AliM';
        text-align: center;
    }

    .j {
        background: #5B78FF;
        width: 10px;
        height: 10px;
        margin-top: 3px;
    }

    .bz {
        background: #22b9ff;
        width: 10px;
        height: 10px;
        margin-top: 3px;
    }

    .dy {
        background: #28a745;
        width: 10px;
        height: 10px;
        margin-top: 3px;
    }

    .jn {
        background: #F74AFF;
        width: 10px;
        height: 10px;
        margin-top: 3px;
    }

    .bg-str {
        font-family: 'AliM';
        text-align: center;
    }

    .u-rig {
        display: flex;
        justify-content: space-between;
        width: 92%;
        margin: auto;
        padding-top: 10px;
        padding-bottom: 30px;
    }

    .txt-cen {
        text-align: center;
    }

    .list {
        background: white;
        /*height: 100vh;*/
        padding: 20px;
        border-radius: 5px;
    }

    .uname {
        font-size: 18px;
        font-family: 'AliM';
        margin-bottom: 15px;
    }
</style>
</body>
</html>
